/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.agenda.model.entity;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Ronildo
 */
@Entity
@Table(name = "AM_TB_TIPO_USUA")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "AmTbTipoUsua.findAll", query = "SELECT a FROM AmTbTipoUsua a"),
    @NamedQuery(name = "AmTbTipoUsua.findByCdTipoUsua", query = "SELECT a FROM AmTbTipoUsua a WHERE a.cdTipoUsua = :cdTipoUsua"),
    @NamedQuery(name = "AmTbTipoUsua.findByDsTipoUsua", query = "SELECT a FROM AmTbTipoUsua a WHERE a.dsTipoUsua = :dsTipoUsua")})
public class AmTbTipoUsua implements Serializable {
    private static final long serialVersionUID = 1L;
    
    @Id
    @Basic(optional = false)
    @Column(name = "CD_TIPO_USUA")
    @GeneratedValue(strategy=GenerationType.SEQUENCE, generator = "seq_AM_TB_TIPO_USUA")
    @SequenceGenerator(name="seq_AM_TB_TIPO_USUA", sequenceName = "seq_AM_TB_TIPO_USUA")
    private Short cdTipoUsua;
    
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 20)
    @Column(name = "DS_TIPO_USUA")
    private String dsTipoUsua;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "cdTipoUsua")
    private Collection<AmTbUsuaSist> amTbUsuaSistCollection;

    public AmTbTipoUsua() {
    }

    public AmTbTipoUsua(Short cdTipoUsua) {
        this.cdTipoUsua = cdTipoUsua;
    }

    public AmTbTipoUsua(Short cdTipoUsua, String dsTipoUsua) {
        this.cdTipoUsua = cdTipoUsua;
        this.dsTipoUsua = dsTipoUsua;
    }

    public Short getCdTipoUsua() {
        return cdTipoUsua;
    }

    public void setCdTipoUsua(Short cdTipoUsua) {
        this.cdTipoUsua = cdTipoUsua;
    }

    public String getDsTipoUsua() {
        return dsTipoUsua;
    }

    public void setDsTipoUsua(String dsTipoUsua) {
        this.dsTipoUsua = dsTipoUsua;
    }

    @XmlTransient
    public Collection<AmTbUsuaSist> getAmTbUsuaSistCollection() {
        return amTbUsuaSistCollection;
    }

    public void setAmTbUsuaSistCollection(Collection<AmTbUsuaSist> amTbUsuaSistCollection) {
        this.amTbUsuaSistCollection = amTbUsuaSistCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (cdTipoUsua != null ? cdTipoUsua.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof AmTbTipoUsua)) {
            return false;
        }
        AmTbTipoUsua other = (AmTbTipoUsua) object;
        if ((this.cdTipoUsua == null && other.cdTipoUsua != null) || (this.cdTipoUsua != null && !this.cdTipoUsua.equals(other.cdTipoUsua))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.agenda.model.entity.AmTbTipoUsua[ cdTipoUsua=" + cdTipoUsua + " ]";
    }
    
}
